<!-- <h1>Listing users</h1> -->
<!DOCTYPE html>
<head>
	<!--<% content_for :title, t("usermanager") %>-->
	<% content_for :title, t(:usermanager) %>
	<%= stylesheet_link_tag "style" %>

	<script type = "text/javascript">
				function ValidatecheckAll(){
		var giatri = document.getElementById("userdeleteAll");
		var chk = document.getElementsByName('userdelete[]');
		if (giatri.checked == true)
		{
		for(i=0; i<chk.length; i++)
		{
		chk[i].checked = true;
		}
		}
		else
		{
		for(i=0; i<chk.length; i++)
		{
		chk[i].checked = false;
		}
		}
		}

		function checkDelete(){
		var del = document.getElementsByName('userdelete[]');
		var flag = 0;
		for(i=0; i<del.length; i++)
		{
		if (del[i].checked == true)
		flag++;
		}
		if (flag<1)
		{
		alert ("<%= t :alertUser%>
			");
			return false;
			}
			else {
			return confirm("
<%= t :confirm%>"+""+flag+""+"<%= t :user%>"+"?");

		}
		}
	</script>
</head>

<body id="book-cover">
	<div class="feat_prod_box_details">
		<div class="contact_form1">
			<div class="form_subtitle">
				<%= t :listuser %>
			</div>
			<%if @users.count >0%>
			<form accept-charset="UTF-8" action="manageruser/destroy" method="post" onsubmit = "return checkDelete()">
				<div style="margin:0;padding:0;display:inline">
				<input name="utf8" type="hidden" value="&#x2713;" />
				<input name="authenticity_token" type="hidden" value="uEyYOD8+56T1blReUq2JsJImeHq9qK/UcHPh8DR1PGM=" />
				</div>
				<div id="book_manager">
				<table class="table">
					<tr class="book_manager">
					<th class="table">
					<div class="book_manager_title_font">
					<%= t :userava %>
					</div>
					</th>
					<th class="table">
					<%= t :details %>
					</th>
					<th class="table"><%= t :action %></th>
					<!--     <th><%= check_box_tag 'userdeleteAll', -1 %></th> -->
					<th class="table"><input id="userdeleteAll" name="userdeleteAll" type="checkbox" value="-1" onclick="return ValidatecheckAll()"/></th>
					</tr>
				<div class="book_color">
				<% i=0%>
				<% @users.each do |aUser| %>
				<% aProfile=@profiles[i]%>
				<% i+=1%>
				<% if aUser.id != session[:user].id %>
				<tr>
					<td width="20%" class="table1">
						<strong class= "bookimage"><%= image_tag aProfile.avatar.url(:small) %></strong>
					</td>
					<td width="55%" class="table">
					<p>
						<div class="form_row">
							<strong class="book_name"><%= t("firstname") %></strong>
							<b><span class="book_value"><%= aProfile.firstname %></span></b>
						</div>
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("lastname") %></strong>
						<b><span class="book_value"><%= aProfile.lastname %></span></b>
					</div> 
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("mssv") %></strong>
						<b><span class="book_value"><%= aProfile.mssv %></span></b>
					</div> 
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("birthday") %></strong>
						<b><span class="book_value"><%= aProfile.birth_of_day %></span></b>
					</div> 
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("address") %></strong>
						<b><span class="book_value"><%= aProfile.address %></span></b>
					</div> 
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("email") %></strong>
						<b><span class="book_value"><%= aUser.email %></span></b>
					</div> 
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("username") %></strong>
						<b><span class="book_value"><%= aUser.username %></span></b>
					</div> 
					</p>
					<p>
					<div class="form_row">
						<strong class="book_name"><%= t("role") %></strong>
						<b><span class="book_value"><%= aUser.role %></span></b>
					</div> 
					</p> 
					</td>
					<td width="30%" class="table" class="">
						
							<%if session[:language] == "vi"%>
	<strong class="changepass"><%= link_to t("edit"), edit_manageruser_path(aUser.id)+"?lang=vi" %>
	<%else%>
	<strong class="changepass"><%= link_to t("edit"), edit_manageruser_path(aUser.id) %>
	<%end%>
						</strong>
					</td>
					<td class="table" width="5%"><%= check_box_tag 'userdelete[]', aUser.id %></td>
				</tr>
				<% end %>
				
		</div>
		<% end %>
	</table>
	</div>
	<div class="form_row">
		<input type="submit" class="register" value="<%= t :delete %>" />
	</div>
	</div>
	</form>
	<%end%>
	

	<br />

	<div class="fieldLabel"></div>
	<%if session[:language] == "vi"%>
	<strong class="changepass"><%= link_to t("newuser"), new_manageruser_path+"?lang=vi" %></strong>
	<%else%>
	<strong class="changepass"><%= link_to t("newuser"), new_manageruser_path %></strong>
	<%end%>
	</div>

</body>
